
import java.io.IOException;
import java.util.List;
import java.util.Vector;

public class Reader {

    private Vector<Problem> problems = new Vector<>();

    public static java.util.List<Problem> getProblems(String file) throws IOException, Exception {

        return Reader.getProblems(file, 10);
    }

    public static java.util.List<Problem> getProblems(String file, int count) throws IOException, Exception {

        var instance = new Reader();
        instance.readFile(file);

        List<Problem> problems = Problem.shuffle(instance.problems).subList(0, count);

        return problems;
    }

    public void readFile(String filename) throws IOException, Exception {

        CsvParser csv = new CsvParser(filename);

        while (true) {
            var line = csv.getLineContentVector();

            if (line == null) {
                break;
            }

            Problem p = new Problem(line.get(0), line.get(1), line.get(2));
            this.problems.add(p);
        }
    }

}
